import { useNuxtApp } from "#app";

const baseUrl = "/video-analysis";
export const getAnalysisList = async (data) => {
  const { $httpRequest } = useNuxtApp(); // 同样获取 $httpRequest
  return await $httpRequest.GET(`${baseUrl}/list`, data);
};

export const getAnalysisItem = async (id) => {
  const { $httpRequest } = useNuxtApp(); // 同样获取 $httpRequest
  return await $httpRequest.GET(`${baseUrl}/${id}`);
};

export const addAnalysis = async (uri, language) => {
  const { $httpRequest } = useNuxtApp(); // 同样获取 $httpRequest
  return await $httpRequest.POST(`${baseUrl}/add`, { uri, language });
};

export const downloadAnalysis = async (id) => {
  const { $httpRequest } = useNuxtApp(); // 同样获取 $httpRequest
  return await $httpRequest.DOWNLOAD(
    `${baseUrl}/export/${id}`,
    {},
    `${id}_${new Date().getTime()}.xlsx`
  );
};

export const delAnalysis = async (id) => {
  const { $httpRequest } = useNuxtApp(); // 同样获取 $httpRequest
  return await $httpRequest.POST(`${baseUrl}/delete/${id}`);
};
